#include<iostream>
using namespace std;
long long a = 1;
const long long mod = 1000000007;

long long f(int A){
    return ((A%mod)*(A%mod+5)%mod)%mod;
}

int main(){
    long long sum = 1;
    for(int i=1;i<30;i++){
        long long temp = f(a);
        sum = (sum%mod+temp%mod)%mod;
        a = temp;
    }
    cout<<sum<<endl;
    //system("pause");
    return 0;
}